package com.iyoudoock.citymine.constants;

import android.text.TextUtils;

import com.kvin.toolkit.utils.StringUtils;

import java.util.HashMap;

/**
 * Created by Kvin on 2017/5/23.
 */
public class HttpUtils {
    //    public static final static String BASE_URL = "http://192.168.1.141:8080/kuangshan/";  //本地测试
    public static final String BASE_URL = "http://101.201.72.86/kuangshan/";  //服务器测试地址

    public static final int PAGE_SIZE = 10;

    /**
     * get login params
     * <p>
     * params.put("macId", macId);
     * params.put("username", username);
     * params.put("password", password);
     * params.put("longitude", longitude);、、necessary
     * params.put("latitude", latitude);、、necessary
     * HashMap<String,String> params=new HashMap<>();
     * params.post(URL + "user/loginCheck");
     */
    public static HashMap<String, String> getLoginParams(String macId, String userName, String psw) {
        HashMap<String, String> params = new HashMap<>();
        params.put(Key.User.MAC_ID, macId);
        params.put(Key.User.NICK_NAME, userName);
        params.put(Key.User.PASSWORD, psw);
        params.put(Key.User.LONGITUDE, "0.0");
        params.put(Key.User.LATITUDE, "0.0");
        return params;
    }

    public static final String LOGIN_URL = BASE_URL + "user/loginCheck";

    /**
     * get register params
     * <p>
     * request.put("telephone", telephone);
     * request.put("type", type);
     * request.put("username", username);
     * request.put("sex", sex);
     * request.put("age", age);
     * request.put("address", address);
     * request.put("password", password);
     * request.put("workTime", wordTime);
     * request.put("company_name", company_name);
     * request.put("company_property", company_property);
     * request.put("company_type", company_type);
     * request.put("company_fax", company_fax);
     * request.put("headImage", headImage);
     * request.put("IDCard_front_images", IDCard_person_images);
     * request.put("IDCard_back_images", IDCard_back_images);
     * request.put("IDCard_person_images", IDCard_front_images);
     * request.put("car_images", car_images);
     * request.put("company_image", company_images);
     * request.put("company_ticket", company_ticket);
     * request.put("company_area", company_area);
     * request.put("pay_type", pay_type);
     * request.put("pay_timeline", pay_timeline);
     * request.put("longitude", longitude);
     * request.put("latitude", latitude);
     * request.put("village", village);
     * HashMap<String,String> params=new HashMap<>();
     * params.post(URL + "user/register");
     */
    public static HashMap<String, String> getRegisterParams(String phoneNo, String roleType, String userName, String sex, String age,
                                                            String address, String registerPersonImage, String registerIDCardFront, String registerIDCardBack, String registerCarImage,
                                                            String psw, String workTime, String companyName, String companyProperty, String companyType,
                                                            String companyFax, String companyImage, String companyTicket, String companyArea, String headImage,
                                                            String payTime, String payTimeLine, String villageId) {
        HashMap<String, String> params = new HashMap<>();
        params.put(Key.User.TELEPHONE, phoneNo);
        params.put(Key.User.ROLE_TYPE, roleType);
        params.put(Key.User.NICK_NAME, userName);
        params.put(Key.User.SEX, sex);
        params.put(Key.User.AGE, age);
        params.put(Key.User.ADDRESS, address);
        params.put(Key.User.PASSWORD, psw);
        params.put(Key.User.WORK_TIME, workTime);
        params.put(Key.User.COMPANY_NAME, companyName);
        params.put(Key.User.COMPANY_PROPERTY, companyProperty);
        params.put(Key.User.COMPANY_TYPE, companyType);
        params.put(Key.User.COMPANY_FAX, companyFax);
        params.put(Key.User.COMPANY_IMAGE, companyImage);
        params.put(Key.User.COMPANY_TICKET, companyTicket);
        params.put(Key.User.COMPANY_AREA, companyArea);
        params.put(Key.User.HEAD_IMAGE, headImage);
        params.put(Key.User.REGISTER_PERSON_IMAGES, registerPersonImage);
        params.put(Key.User.REGISTER_IDCARD_FRONT, registerIDCardFront);
        params.put(Key.User.REGISTER_IDCARD_BACK, registerIDCardBack);
        params.put(Key.User.REGISTER_CAR_IMAGES, registerCarImage);
        params.put(Key.User.PAY_TYPE, payTime);
        params.put(Key.User.PAY_TIMELINE, payTimeLine);
        params.put(Key.User.DISTRICT_ID, villageId);
        params.put(Key.User.LONGITUDE, String.valueOf(0.0));
        params.put(Key.User.LATITUDE, String.valueOf(0.0));
        return params;
    }

    public static HashMap<String, String> getRegisterParams(String phoneNo, String roleType, String userName, String sex, String age,
                                                            String address, String registerPersonImage, String registerIDCardFront, String registerIDCardBack, String registerCarImage,
                                                            String psw, String villegeId) {
        return getRegisterParams(phoneNo, roleType, userName, sex, age, address, registerPersonImage, registerIDCardFront, registerIDCardBack,
                registerCarImage, psw, "", "", "", "", "", "", "", "", "", "", "", villegeId);
    }

    public static final String REGISTER_URL = BASE_URL + "user/register";

    /**
     * get login params
     * params.put("uid", uid);
     * params.put("latitude", latitude);
     * params.put("longitude", longitude);
     * params.put("distance", distence);
     * params.put("limit", limit);
     * params.put("tag", tag);
     * HashMap<String,String> params=new HashMap<>();
     * params.post(URL + "map/around");
     */
    public static HashMap<String, String> getAroundRecyclerParams(String uid, String longitude, String latitude, String distance, String tag) {
        HashMap<String, String> params = new HashMap<>();
        params.put(Key.User.UID, uid);
        params.put(Key.User.LONGITUDE, longitude);
        params.put(Key.User.LATITUDE, latitude);
        params.put(Key.User.DISTANCE, distance);
        params.put(Key.User.LIMIT, String.valueOf(1000));
        params.put(Key.User.TAG, tag);
        return params;
    }

    public static final String AROUND_RECYCLER_URL = BASE_URL + "map/around";


    /**
     * params.put("mobile", Phone);
     * params.put("type", type);//0 update psw   1 register
     * HashMap<String,String> params=new HashMap<>();
     * params.post(URL + "validcode/sendSms");
     */
    public static HashMap<String, String> getVerifyCodeParams(String phoneNo, String verifyType) {
        HashMap<String, String> params = new HashMap<>();
        params.put(Key.User.MOBILE, phoneNo);
        params.put(Key.User.VERIFY_TYPE, verifyType);
        return params;
    }

    public static final String VERIFY_CODE_URL = BASE_URL + "validcode/sendSms";


    // 判断验证码正确与否
    public static HashMap<String, String> checkVerifyCode(String phone, String validCode) {
        HashMap<String, String> params = new HashMap<>();

        params.put("mobile", phone);
        params.put("validCode", validCode);
        return params;
    }

    public static final String CHECK_VERIFYCODE_URL = BASE_URL + "validcode/validSmsCode";

    // 发单接口
    public static HashMap<String, String> sendOrder(String uid, String recycleNo, String longitude,
                                                    String latitude, String raidus, String remark, String pickTime,
                                                    String pickAddress, String items, String recycleName) {
        HashMap<String, String> params = new HashMap<>();
        params.put("submit.uid", uid);
        params.put("recycleNo", recycleNo);
        params.put("longitude", longitude);
        params.put("latitude", latitude);
        params.put("raidus", raidus);
        params.put("remark", remark);
        params.put("pickTime", pickTime);
        params.put("pickAddress", pickAddress);
        params.put("items", items);
        params.put("recycleName", recycleName);
        return params;
    }

    public static final String SEND_ORDER_URL = BASE_URL + "order/submit";


    // 定单详细信息
    public static HashMap<String, String> orderDetail(String order) {
        HashMap<String, String> params = new HashMap<>();
        params.put("order", order);
        return params;
    }

    public static final String ORDER_DETAIL_URL = BASE_URL + "order/detail";

    /**
     * category query
     * @param recyclerNo
     * @param catagory_id
     * @param parent_id
     * @return
     */
    public static HashMap<String, String> categoryQuery(String recyclerNo, String catagory_id, String parent_id) {
        HashMap<String, String> params = new HashMap<>();
        params.put("parent_id", parent_id);
        params.put("no", recyclerNo);
        params.put("catagory_id", catagory_id);
        return params;
    }

    public static final String CATEGORY_QUERY_URL = BASE_URL + "type/queryType";
    public static final String CATEGORY_DETAIL_URL = BASE_URL + "info/categoryEditAble?uid=";

    // 抢单||接单
    public static HashMap<String, String> orderAccept(String uid, String order, String total) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("order", order);
        params.put("total", total);
        return params;
    }

    public static final String ACCEPT_ORDER_URL = BASE_URL + "order/accept";

    // 取消订单接口 tatus:订单状态 finish_cancel（客户取消）|finish_timeout（锁订单）
    public static HashMap<String, String> cancelOrder(String uid, String order_id, String status) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("order", order_id);
        params.put("status", status);
        return params;
    }

    public static final String CANCEL_ORDER_URL = BASE_URL + "order/cancel";

    // 重新发单接口
    public static HashMap<String, String> reSendOrder(String longitude, String latitude, String raidus,
                                                      String order) {
        HashMap<String, String> params = new HashMap<>();
        params.put("longitude", longitude);
        params.put("latitude", latitude);
        params.put("raidus", raidus);
        params.put("order", order);
        return params;
    }

    public static final String RESEND_ORDER_URL = BASE_URL + "order/resend";


    /**
     *
     * @author 王刚
     * @date 2016-4-25 上午11:16:01
     * @descripton 上报经纬度
     */
    public static HashMap<String, String> logout(String uid, String latitude, String longitude,String macId) {
        HashMap<String, String> params = new HashMap<>();
        params.put(Key.User.UID, uid);
        params.put(Key.User.LATITUDE, StringUtils.isEmpty(latitude) ? "0.0" : latitude);
        params.put(Key.User.LONGITUDE, StringUtils.isEmpty(longitude) ? "0.0" : longitude);
        params.put(Key.User.LOCATION_STATUS, "0");
        params.put(Key.User.MAC_ID, macId);
        params.put(Key.Param.LOGOUT, "0");
        params.put(Key.Param.IS_CHANGE_IDENTITY, "0");
        return params;
    }

    public static final String LOGOUT_URL = BASE_URL + "map/reportLocation";

    /**
     *
     * @param uid
     * @param latitude
     * @param longitude
     * @param macId
     * logout   1表示登录，0表示退出登录
     *          isChangeIdentity      是否是身份变更的退出登录 1：需要更新0：不需要更新
     * @return
     */
    public static HashMap<String, String> uploadlatlng(String uid, String latitude, String longitude,String macId) {
        HashMap<String, String> params = new HashMap<>();
        params.put(Key.User.UID, uid);
        params.put(Key.User.LATITUDE, StringUtils.isEmpty(latitude) ? "0.0" : latitude);
        params.put(Key.User.LONGITUDE, StringUtils.isEmpty(longitude) ? "0.0" : longitude);
        params.put(Key.User.LOCATION_STATUS, "1");
        params.put(Key.User.MAC_ID, macId);
        params.put(Key.Param.LOGOUT, "1");
        params.put(Key.Param.IS_CHANGE_IDENTITY, "1");
        return params;
    }

    public static final String UPLOAD_LATLNG = BASE_URL + "map/reportLocation";



    // 收货完成
    public static HashMap<String, String> orderFinish(String uid, String order) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);// 用户id
        params.put("order", order);// 单号
        return params;
    }

    public static final String ORDER_FINISH_URL = BASE_URL + "order/finish";

    // 拉取推送到B的订单
    public static HashMap<String, String> orderPushToB(String uid, String page) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);// 用户id
        params.put("page", page);// 单号
        return params;
    }

    public static final String ORDER_PUSH_B_URL = BASE_URL + "order/pushToB";

    // 添加b品类
    public static HashMap<String, String> addCategoryToUser(String state, String array) {
        HashMap<String, String> params = new HashMap<>();
        params.put("state", state);
        params.put("data", array);// json字符串
        return params;
    }

    public static final String ADD_CATEGORY_URL = BASE_URL + "type/addCategoryToUser";


    // 我的订单
    public static HashMap<String, String> myOrder(String uid, String roleType, String status, String page) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);// 用户id
        params.put("type", roleType);// 用户类型
        params.put("status", status);// 订单状态
        params.put("page", page);//
        params.put("limit", String.valueOf(PAGE_SIZE));//
        return params;
    }

    public static final String MY_ORDER_URL = BASE_URL + "order/my";

    // A用户的我的订单接口
    public static HashMap<String, String> myOrder(String uid, String type, String status, int page, int limit) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("type", type);
        params.put("status", status);
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));
        return params;
    }

    // 添加收藏或加入黑名单接口,type：操作类型( black:黑名单, collect:收藏)
    public static HashMap<String, String> addToCollectOrBlackList(String myId, String targetId, String type) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", myId);
        params.put("beAddUser", targetId);
        params.put("type", type);
        return params;
    }

    public static final String ADD_BLACKLIST_URL = BASE_URL + "user/addBlackOrFavour";

    // 取消收藏或移出黑名单接口 ,type：操作类型( black:黑名单, collect:收藏)
    public static HashMap<String, String> removeFromCollectOrBlackList(String myId, String targetId, String type) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", myId);
        params.put("beDeleteUser", targetId);
        params.put("type", type);
        return params;
    }

    public static final String REMOVE_BLACKLIST_URL = BASE_URL + "user/deleteBlackOrFavour";

    // 删除订单接口
    public static HashMap<String, String> deleteOrder(String uid, String order) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("order", order);
        return params;
    }

    public static final String DELETE_ORDER_URL = BASE_URL + "order/delete";

    // 我的黑名单或者收藏夹，type：操作类型( black:黑名单, collect:收藏)
    public static HashMap<String, String> selectMyBlackOrCollect(String uid, String type, int page, int limit) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("type", type);
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));
        return params;
    }

    public static final String BALCKLIST_INFO_URL = BASE_URL + "user/blackOrFavourList";


    // 意见反馈接口
    public static HashMap<String, String> feedback(String uid, String content) {
        HashMap<String, String> params = new HashMap<>();
        params.put("submit.uid", uid);
        params.put("content", content);
        return params;
    }

    public static final String FEEDBACK_URL = BASE_URL + "info/feedback";

    // 投诉接口
    public static HashMap<String, String> complaint(String myId, String targerId, String orderId,
                                                    String content) {
        HashMap<String, String> params = new HashMap<>();
        params.put("complaint.uid", myId);
        params.put("target.uid", targerId);
        params.put("order.id", orderId);
        params.put("content", content);
        params.put("status", "未处理");
        return params;
    }

    public static final String COMPLAINT_URL = BASE_URL + "info/complaint";

    // 资讯列表接口
    public static HashMap<String, String> newsList(int page, int limit) {
        HashMap<String, String> params = new HashMap<>();
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));
        return params;
    }

    public static final String NEWS_URL = BASE_URL + "info/informationList";

    // 找回密码接口
    public static HashMap<String, String> resetPsd(String telephone, String password) {
        HashMap<String, String> params = new HashMap<>();
        params.put("telephone", telephone);
        params.put("password", password);
        return params;
    }

    public static final String RESET_PSW_URL = BASE_URL + "user/forgetPassword";

    // 修改个人接
    public static HashMap<String, String> updateUserInfo(String uid, String username, String sex,
                                                         String age, String address, String latitude, String longitude,
                                                         String workTime, String telephone, String company_name,
                                                         String company_property, String company_type, String company_fax,
                                                         String company_ticket, String company_area, String pay_type,
                                                         String pay_timeline, String village) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("username", username);
        params.put("sex", sex);
        params.put("age", age);
        params.put("address", address);
        params.put("latitude", TextUtils.isEmpty(latitude) ? "0.0" : latitude);
        params.put("longitude", TextUtils.isEmpty(longitude) ? "0.0" : longitude);
        params.put("workTime", workTime);
        params.put("telephone", telephone);
        params.put("company_name", company_name);
        params.put("company_property", company_property);
        params.put("company_type", company_type);
        params.put("company_fax", company_fax);
        params.put("company_ticket", company_ticket);
        params.put("company_area", company_area);
        params.put("pay_type", pay_type);
        params.put("pay_timeline", pay_timeline);
        params.put("village", village);
        return params;
    }

    public static final String UPDATE_USERINFO_URL = BASE_URL + "user/updateUserInfo";


    // 评价接口
    public static HashMap<String, String> comment(String orderId, String point) {
        HashMap<String, String> params = new HashMap<>();
        params.put("id", orderId);
        params.put("score", point);
        return params;

    }

    public static final String COMMENT_URL = BASE_URL + "order/evaluateScore";

    // 获取当前用户积分接口
    public static HashMap<String, String> getIntegral(String uid) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        return params;
    }

    public static final String INTEGRAL_URL = BASE_URL + "user/getIntegral";

    public static final String GOOD_TYPE_URL = BASE_URL + "integration/typeList";


    // 获取商品列表接口
    public static HashMap<String, String> getGoods(int page, int limit, String typeId) {
        HashMap<String, String> params = new HashMap<>();
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));
        params.put("typeId", typeId);
        return params;
    }

    public static final String GOOD_LIST_URL = BASE_URL + "integration/goodList";

    // 商品详情接口
    public static HashMap<String, String> getGoodDetial(String goodId) {
        HashMap<String, String> params = new HashMap<>();
        params.put("id", goodId);
        return params;
    }

    public static final String GOOD_DETAIL_URL = BASE_URL + "integration/goodDetail";

    // 积分兑换接口
    public static HashMap<String, String> integralExchange(String submit_uid, String goodId) {
        HashMap<String, String> params = new HashMap<>();
        params.put("submit_uid", submit_uid);
        params.put("goodId", goodId);
        return params;
    }

    public static final String INTEGRAL_EXCHANGE_URL = BASE_URL + "integration/exchange";

    // 使用帮助和用户协议接口 type(help使用帮助 law用户协议)
    public static HashMap<String, String> helpAndLaw(String type) {
        HashMap<String, String> params = new HashMap<>();
        params.put("type", type);
        return params;
    }

    public static final String HELP_URL = BASE_URL + "info/queryInfo";

    // 分享加积分接口
    public static HashMap<String, String> shareIntegral(String uid, String score) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("score", score);
        return params;
    }

    public static final String SHARE_INTEGRAL_URL = BASE_URL + "user/sharePlusScore";

    //是否有其他机器登录账号

    /**
     * response loginState={1表示没有人登录，0表示有人登录，-1表示有人登录过 ，但是退出了}
     * @param uid
     * @param macID
     * @return
     */
    public static HashMap<String, String> isLogin(String uid, String macID) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("macId", macID);
        return params;

    }

    public static final String IS_LOGIN_URL = BASE_URL + "user/isLogin";


    /**
     * 根据省市区信息及关键字查询小区信息
     *
     * @param province 省份 可选
     * @param city     城市
     * @param district 区、县
     * @param key      小区关键字
     * @return
     */
    public static HashMap<String, String> getDistrictInfo(String province, String city, String district, String key) {
        HashMap<String, String> params = new HashMap<>();
        params.put("province", province);
        params.put("city", city);
        params.put("district", district);
        params.put("key", key);
        return params;
    }

    public static final String DISTRICT_INFO_URL = BASE_URL + "geo/villages/list";

    /**
     * @param uid
     * @param acceptState 1:接收/恢复订单推送,0:暂停接收订单
     * @author 王刚
     * @date 2016-4-15 下午5:53:50
     * @descripton 停止接单和回复接单的接口
     */
    public static HashMap<String, String> launchAcceptOrder(String uid, int acceptState) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("acceptOrder", String.valueOf(acceptState));
        return params;
    }

    public static final String LAUNCH_ACCEPT_URL = BASE_URL + "user/switchAcceptOrderState";

    /**
     * @param uid       用户id
     * @param villageId 小区id
     * @param type      要更改的类型
     *                  between B1 and B2
     * @author 王刚
     * @date 2016-4-22 下午1:54:30
     * @descripton 身份变更接口
     */
    public static HashMap<String, String> changeIdentity(String uid, String villageId, String type) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        params.put("villageId", villageId);
        params.put("turnCate", type);
        return params;
    }

    public static final String CHANGE_IDENTITY_URL = BASE_URL + "userTurnCate/add";

    /**
     * @param uid
     * @author 王刚
     * @date 2016-4-22 下午2:37:30
     * @descripton 查询身份变更进度接口
     */
    public static HashMap<String, String> queryIdentityProcess(String uid) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        return params;
    }

    public static final String QUERY_IDENTITY_URL = BASE_URL + "userTurnCate/list";

    /**
     * @param uid
     * @author 王刚
     * @date 2016-4-25 下午3:21:47
     * @descripton 检查用户是否有未完成的订单
     */
    public static HashMap<String, String> unfinishedOrderList(String uid) {
        HashMap<String, String> params = new HashMap<>();
        params.put("uid", uid);
        return params;
    }

    public static final String UNFINISHED_ORDER_URL = BASE_URL + "order/notFinished";

}
